﻿using System;
using log4net;
using log4net.Config;

namespace Utils
{
    /// <summary>
    /// Singleton class
    /// This encapsulates all of the logging functionality
    /// It acts as a wrapper for the log4net library
    /// </summary>
    public class Logger
    {
        //log4net hook
        private static readonly ILog logger;
        //singleton instance
        private static Logger innerInstance = null;
        //singleton constructor
        static Logger()
        {
            XmlConfigurator.Configure();
            logger = LogManager.GetLogger(typeof (Logger));
        }
        /// <summary>
        /// public access for the singleton instance
        /// </summary>
        public static Logger Instance
        {
            get
            {
                if (innerInstance == null)
                    innerInstance = new Logger();
                return innerInstance;
            }
        }
        /// <summary>
        /// add more of these as the need arises
        /// </summary>
        /// <param name="e"></param>
        public void LogException(Exception e)
        {
            logger.Error(null, e);
        }
    }
}